/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.crm.store;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.jdbc.OracleTypes;
import queenb.net.datacontrol.DataStatement;
import queenb.net.datacontrol.Param;
import queenb.net.entitybean.K230;
import queenb.web.crm.inteface.K230Inf;
import queenb.web.util.PackageContants;

/**
 *
 * @author Thanh Luan
 */
public class K230Store extends K230 implements K230Inf {

    @Override
    public int updateK230By(int pnPK230, int pnFH000, int pnFH200,
            int pnFK100, int pnFK220, String pvKV231,
            Date pdKD232, String pvKB233, int pnKN234,
            int pnKN235, String pvLOGIN) {
        try {
            DataStatement dateStatement = new DataStatement(PackageContants.UPDATE_K230, OracleTypes.INTEGER, new Param[]{
                        new Param(OracleTypes.INTEGER, pnPK230),
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.INTEGER, pnFK100),
                        new Param(OracleTypes.INTEGER, pnFK220),
                        new Param(OracleTypes.CHAR, pvKV231),
                        new Param(OracleTypes.DATE, pdKD232),
                        new Param(OracleTypes.CHAR, pvKB233),
                        new Param(OracleTypes.INTEGER, pnKN234),
                        new Param(OracleTypes.INTEGER, pnKN235),
                        new Param(OracleTypes.CHAR, pvLOGIN)});
            return super.update(dateStatement, K230.class);
        } catch (SQLException ex) {
            Logger.getLogger(K230Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }
    }

    @Override
    public int deleteK230(int pnPK230, String pvLOGIN) {
        DataStatement dataStatement = new DataStatement(PackageContants.DELETE_K230, OracleTypes.INTEGER, new Param[]{
                    new Param(OracleTypes.INTEGER, pnPK230),
                    new Param(OracleTypes.CHAR, pvLOGIN)});
        try {
            return super.update(dataStatement, K230.class);
        } catch (SQLException ex) {
            Logger.getLogger(K230Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }
    }

    @Override
    public List<K230> getListTabK230(int pnFH000, int pnFH200, int pnFK100, int pnOFFSET, int pnLIMIT,
            int pnSORT, int pnDIRECTION, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.LIST_K950, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.INTEGER, pnFK100),
                        new Param(OracleTypes.INTEGER, pnOFFSET),
                        new Param(OracleTypes.INTEGER, pnLIMIT),
                        new Param(OracleTypes.INTEGER, pnSORT),
                        new Param(OracleTypes.INTEGER, pnDIRECTION),
                        new Param(OracleTypes.CHAR, pvLOGIN)});
            return super.find(dataStatement, K230.class);
        } catch (SQLException ex) {
            Logger.getLogger(K230Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(K230Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(K230Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
}
